package quiz.pack;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class IFileReader {
public Quiz readquiz(String filepath){
	String[] ans = null;
	String[] ques = null;
	int[] corans = null;
	try {
		Scanner scan = new Scanner(new File(filepath));
		String qnums = scan.nextLine();
		int qnum = Integer.parseInt(qnums);
		System.out.print(qnum+"\n");
		corans = new int[qnum];
		ans = new String[qnum*4];
		 ques = new String[qnum];
		for(int i = 0;i<qnum;i++){
			corans[i]=Integer.parseInt(scan.nextLine());
			System.out.print("Correct Answer for This Question:"+corans[i]+"\n");
				ques[i]=scan.nextLine();
				System.out.println("Question:"+ques[i]+"\n");
				ans[(i*4)]=scan.nextLine();
				System.out.println("Answer 1:"+ans[i*4]+"\n");
				ans[(i*4)+1]=scan.nextLine();
				System.out.println("Answer 2:"+ans[i*4+1]+"\n");
				ans[(i*4)+2]=scan.nextLine();
				System.out.println("Answer 3:"+ans[i*4+2]+"\n");
				ans[(i*4)+3]=scan.nextLine();
				System.out.println("Answer 4:"+ans[i*4+3]+"\n");
		}
		
	} catch (FileNotFoundException e) {
		e.printStackTrace();
	}
	return new Quiz(ans,ques,corans);
}
}
